/*
 * library2.cpp
 *
 *  Created on: 14/12/2011
 *      Author: Idan
 */
using namespace std;
#include "library2.h"
#include "union_find.h"
void* Init(bool sectionB){
	Lego* DS = sectionB? new Lego2:new Lego;
    return (void*)DS;
}

StatusType  AddCube(void* DS, int height, int width){
	try{
		if(!DS) return INVALID_INPUT;
		return ((Lego*)DS)->addCube(height,width);
	}catch(bad_alloc& e){
		return ALLOCATION_ERROR;
	}
}
StatusType  PutOnTop(void* DS, int cubeUp, int cubeDown){
	try{
		if(!DS) return INVALID_INPUT;
		return ((Lego*)DS)->putOnTop(cubeUp,cubeDown);
	}catch(bad_alloc& e){
		return ALLOCATION_ERROR;
	}
}

StatusType  TowerHeight(void* DS, int cube, int* height){
	if(!DS) return INVALID_INPUT;
	return ((Lego*)DS)->towerHeight(cube,height);
}

StatusType  HeightFromGround(void* DS, int cube, int* height){
	if(!DS) return INVALID_INPUT;
	return ((Lego*)DS)->HeightFromGround(cube,height);
}
StatusType  TowersOfHeightBetween(void* DS, int min, int max, int* num){
	if(!DS) return INVALID_INPUT;
	return ((Lego*)DS)->TowersOfHeightBetween(min,max,num);
}
void Quit(void** DS){
	delete (Lego*)(*DS);
	*DS = NULL;
}

